<!DOCTYPE html>
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

	<title>软件学院操行管理系统</title>
	<!-- The styles -->
	<link href="css/bootstrap-cerulean.css" rel="stylesheet">
	<link href="css/login.css" rel="stylesheet">
	<link href="css/charisma-app.css" rel="stylesheet">
	<style type="text/css">
		body {
			padding-bottom: 40px;
		}

		.sidebar-nav {
			padding: 9px 0;
		}
	</style>
	<script src="http://lib.sinaapp.com/js/jquery/2.2.4/jquery-2.2.4.min.js"></script>
	<script src="js/bootstrap-dropdown.js"></script>
	<script src="js/common/public.js"></script>
	<script src="js/base64.js"></script>
	<script type="text/javascript">
        $(document).ready(function () {
            //Ajax调用处理
            var urlMsg  = parseUrl(window.location.search);
            if (urlMsg.token!=null){
                var token = decode(urlMsg.token);
			}
            var html = $.ajax({
                type: "GET",
                url: "http://localhost:1066/student/findStudent?token="+token,
                async: false
            }).responseText;
            var result = eval('(' + html + ')');
            if (result.code!=200){
                alert(result.msg)
            }else {
                $("#name").html(result.data.studentInfo.name);
                $("#studentName").html(result.data.studentInfo.name);
                $("#studentNumber").val(result.data.studentInfo.studentNumber);
                $("#studentId").val(result.data.studentInfo.id);
                var score = result.data.studentInfo.score;
                if (score>=140){
                    $("#score").html(result.data.studentInfo.score).css("color","#F1FA28");
				} else if (score>=120) {
                    $("#score").html(result.data.studentInfo.score).css("color","#EB681E");
				}else if (score>=100) {
                    $("#score").html(result.data.studentInfo.score).css("color","#EB1ED2");
                }else if (score>=90) {
                    $("#score").html(result.data.studentInfo.score).css("color","#37EB1F");
                }else if (score>=80) {
                    $("#score").html(result.data.studentInfo.score).css("color","#1F99EB");
                }else if (score>=70) {
                    $("#score").html(result.data.studentInfo.score).css("color","#AF8F8F");
                }else {
                    $("#score").html(result.data.studentInfo.score).css("color","#C42E2E");
				}
                $("#className").html("班级名称："+result.data.classInfo.className);
                $("#classNumber").html("班级编号："+result.data.classInfo.classNumber);
                $("#classScore").html("班级量化："+result.data.classInfo.score);
                $("#monitor").html("班长："+result.data.classInfo.monitor);
                $("#majorName").html("班级名称："+result.data.classInfo.majorName);
                if (result.data.studentScoreInfo==null){
                    $("#studentScoreDetaile tbody").append("<tr><td colspan='4' style='text-align:center;font-size:20px;color:red;'><br>很遗憾，你没有任何操行记录！<br><br></td></tr>");
				}else {
					for (index in result.data.studentScoreInfo) {
                        addStudentScoreTable(result.data.studentScoreInfo[index].finallyScore,
                            result.data.studentScoreInfo[index].reason,
                            result.data.studentScoreInfo[index].remark,
                            result.data.studentScoreInfo[index].page,)
					}
				}
                if (result.data.classScoreInfo==null){
                    $("#classScoreDetaile tbody").append("<tr><td colspan='4' style='text-align:center;font-size:20px;color:red;'><br>很遗憾，班级没有任何量化记录！<br><br></td></tr>");
                }else {
                    for (index in result.data.classScoreInfo) {
                        addClassScoreTable(result.data.classScoreInfo[index].finallyScore,
                            result.data.classScoreInfo[index].reason,
                            result.data.classScoreInfo[index].date,
                            result.data.classScoreInfo[index].page,)
                    }
				}
				if(result.data.studentInfo.duty!="班长"){
                    $("#studentInfo tbody").append("<tr><td colspan='2' style='text-align:center;font-size:15px;color:red;'><br>您不是班长，无权查看此项！<br><br></td></tr>");
                }else {
				    for (index in result.data.studentBOList) {
                        $("#studentInfo tbody").append("<tr><td class='center'>"+result.data.studentBOList[index].name+"</td>" +
							"<td class='center'>"+result.data.studentBOList[index].score+"</td></tr>");
                    }
				}
			}
        })

		function addStudentScoreTable(score,reason,remark,page) {
            if (score>0){
                $("#studentScoreDetaile tbody").append("<tr><td class='center' style='color:green; font-size:20px;text-align:center;'>"+score+"</td>" +
					"<td class='center' style='font-size:15px;'>"+reason+"</td>" +
					"<td class='center' style='font-size:15px;'>"+remark+"</td>" +
					"<td class='center' style='font-size:15px;'>"+page+"</td></tr>");
            } else {
                $("#studentScoreDetaile tbody").append("<tr><td class='center' style='color:red; font-size:20px;text-align:center;'>"+score+"</td>" +
                    "<td class='center' style='font-size:15px;'>"+reason+"</td>" +
                    "<td class='center' style='font-size:15px;'>"+remark+"</td>" +
                    "<td class='center' style='font-size:15px;'>"+page+"</td></tr>");
            }
        }

        function addClassScoreTable(score,reason,date,page) {
            if (score>0){
                $("#classScoreDetaile tbody").append("<tr><td class='center' style='color:green; font-size:20px;text-align:center;'>"+score+"</td>" +
                    "<td class='center' style='font-size:15px;'>"+reason+"</td>" +
                    "<td class='center' style='font-size:15px;'>"+date+"</td>" +
                    "<td class='center' style='font-size:15px;'>"+page+"</td></tr>");
            } else {
                $("#classScoreDetaile tbody").append("<tr><td class='center' style='color:red; font-size:20px;text-align:center;'>"+score+"</td>" +
                    "<td class='center' style='font-size:15px;'>"+reason+"</td>" +
                    "<td class='center' style='font-size:15px;'>"+date+"</td>" +
                    "<td class='center' style='font-size:15px;'>"+page+"</td></tr>");
            }
        }

        function toChangePassword() {
			var studentNumber = $("#studentNumber").val();
			var id = $("#studentId").val();
            var urlMsg  = parseUrl(window.location.search);
            var token = decode(urlMsg.token);
            alert(id)
            window.location.href="changePassword.html?studentNumber="+studentNumber+"&token="+token+"&id="+id;
        }
        function logout() {
            var urlMsg  = parseUrl(window.location.search);
            var token = decode(urlMsg.token);
            var html = $.ajax({
                type: "POST",
                url: "http://localhost:1066/student/logout?token="+token,
                async: false
            }).responseText;
            var result = eval('(' + html + ')');
            if (result.code==200){
                alert(result.msg)
                window.location.href="login.html"
            }
        }
		function findHistory() {
			var urlMsg  = parseUrl(window.location.search);
			var token = decode(urlMsg.token);
			window.location.href="findHistory.html?token="+token;
		}
	</script>
</head>

<body style="width:auto">

<div class="navbar">
	<div class="navbar-inner">
		<div class="container-fluid">
			<a class="btn btn-navbar" data-toggle="collapse"
			   data-target=".top-nav.nav-collapse,.sidebar-nav.nav-collapse">
				<span class="icon-bar"></span>
				<span class="icon-bar"></span>
				<span class="icon-bar"></span>
			</a>
			<a class="brand" href="student.action"> <img src="images/logo20.png"/> <span>软件学院操行管理系统</span></a>
			<a class="brand" href="javascript:findHistory()">  <span>查询历史分数</span></a>
			<div class="btn-group pull-right">
				<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
					<i class="icon-user"></i>
					<span class="hidden-phone" id="studentName"></span>
					<span class="caret"></span>
				</a>
				<ul class="dropdown-menu">
					<li><a href="javascript:toChangePassword()">修改密码</a></li>
					<li class="divider"></li>
					<li><a href="javascript:logout()">安全退出</a></li>
				</ul>
			</div>

		</div>
	</div>
</div>

<div class="container-fluid">
	<div class="row-fluid">
		<div id="content" class="span10" style="width: 78.5%; margin-left: 11%;padding-top:20px;">
			<div class="row-fluid sortable">
				<div class="box span9">
					<div class="box-header well" data-original-title>
						<h2>我的操行分</h2>
					</div>
					<div class="box-content">
						<div class="page-header">
							<h1 style="font-size:50px;padding-left:100px;">欢迎你：</h1>
						</div>
						<div class="row-fluid" style="padding-top: 30px; text-align: center; ">
							<h1 id="name" style="font-size:70px; letter-spacing: 50px;"></h1>
							<input type="hidden" value="" id="studentNumber"/>
							<input type="hidden" value="" id="studentId"/>
						</div>

						<div class="row-fluid">
							<br><br><br><br><br><br>

							<div class="center">
								<h1 id="score" style="padding-left:50px;padding-right:50px;text-align: center;display: inline-block; color:#EB681E;font-size:170px;">
									100</h1>
							</div>
						</div>

						<br>

						<div class="divider-content">
							<span></span>
						</div>

						<br>
						<br>
						<br>

						<!-- start dispaly studentscore detail -->
						<div class="row-fluid">
							<h1 style="font-size:30px;padding-left:100px;">操行详情：</h1>
							<br>
							<br>
							<table id="studentScoreDetaile" class="table table-striped table-bordered bootstrap-datatable">
								<thead>
								<tr>
									<th class="sorting" style="width: 10%; text-align:center;">分值</th>
									<th class="sorting" style="width: 60%;">原因</th>
									<th class="sorting" style="width: 15%;">部门</th>
									<th class="sorting" style="width: 15%;">页码</th>
								</tr>
								</thead>
								<tbody>


								</tbody>
							</table>
						</div>
						<!-- dispaly studentscore detail end-->
						<br>
						<br>
						<br>

						<!-- start dispaly classscore detail -->
						<div class="row-fluid">
							<h1 style="font-size:30px;padding-left:100px;">量化详情：</h1>
							<br>
							<br>
							<table id="classScoreDetaile" class="table table-striped table-bordered bootstrap-datatable">
								<thead>
								<tr>
									<th class="sorting" style="width: 10%; text-align:center;">分值</th>
									<th class="sorting" style="width: 60%;">原因</th>
									<th class="sorting" style="width: 15%;">日期</th>
									<th class="sorting" style="width: 15%;">页码</th>
								</tr>
								</thead>
								<tbody>


								</tbody>
							</table>
						</div>
						<!-- dispaly classscore detail end-->
					</div>
				</div>

				<!-- student info -->
				<div class="box span3">
					<div class="box-header well">
						<h3>班级信息</h3>
					</div>
					<br>
					<div class="box-content">
						<h3 id="classNumber"></h3>
						<br>
						<h3 id="className"></h3>
						<br>
						<h3 id="majorName"></h3>
						<br>
						<h3 id="monitor"></h3>
						<br>
						<h3 id="classScore"></h3>
					</div>
					<br>
				</div>
				<!-- student info end -->

				<!-- top student score -->
				<!--<div class="box span3">
                    <div class="box-header well">
                        <h3>操行排行榜</h3>
                    </div>
                    <div class="box-content">
                        <table class="table table-striped table-bordered bootstrap-datatable">
                          <thead>
                              <tr>
                                  <th class="sorting" style="width: 50%;">姓名</th>
                                  <th class="sorting" style="width: 50%;">操行分</th>
                              </tr>
                          </thead>
                          <tbody>

                          </tbody>
                        </table>
                    </div>
                </div> -->
				<!-- top student score end! -->


				<!-- class all student score -->

				<div class="box span3">
					<div class="box-header well">
						<h3>班级操行</h3>
					</div>
					<div class="box-content">
						<table id="studentInfo" class="table table-striped table-bordered bootstrap-datatable">
							<thead>
							<tr>
								<th class="sorting" style="width: 50%;">姓名</th>
								<th class="sorting" style="width: 50%;">操行分</th>
							</tr>
							</thead>
							<tbody>

							</tbody>
						</table>
					</div>
				</div>

				<!-- class all student score end! -->

			</div>
		</div>
	</div>
	<hr>
	<div id="footer">
		<p style="padding-top:0px; text-align:center; display:block">
			版本所有:<a href="javascript:void(0)">南阳理工软件学院</a>&nbsp;&nbsp;&nbsp;技术支持:<a href="javascript:void(0)">前研工作室</a>
		</p>
	</div>

</div>
</body>
</html>
